package com.weng.cloud.service8882.mock;

import com.cloud.api.mock.MockArgDto;
import com.cloud.api.mock.MockConstants;
import com.cloud.api.mock.MockResDto;
import com.weng.cloud.commons.base.JsonUtil;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Author: weng
 * @Date: 2022/6/11
 * @Description: com.weng.cloud.service8882.mock
 */

@RestController
public class MockService {

    @RequestMapping(value = "/mockService", method = RequestMethod.POST)
    public List<MockResDto> mockService(@RequestBody Map<String,Object> argMap) {
        List<MockArgDto> argDtos = JsonUtil.toList(argMap.get("arg").toString(),MockArgDto.class);
        return doMockService(argDtos);
    }

    private List<MockResDto> doMockService(List<MockArgDto> argDtos) {
        return MockConstants.res(argDtos);
    }
}
